/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import util.HibernateUtil;

/**
 *
 * @author MRDO
 */
public class DataProcess {
    private static Session session;
    
    public DataProcess(){
        SessionFactory factory = HibernateUtil.getSessionFactory();
        this.session = factory.getCurrentSession();
    }
    
    public List getAll(String modelName){
        try {
            session.beginTransaction();
            
            String sql = "from "+modelName;
            Query query = session.createQuery(sql);
            List list = query.list();
            
            session.getTransaction().commit();
            return list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
